<template>
  <div class="mask" v-if="visable">
    <div class="wrap">
      <div class="tip">
        <slot name="tip"></slot>
      </div>
      <div class="content">
        <slot name="content"></slot>
      </div>
      <div class="button">
        <button class="mask__button--success" @click="success">确定</button>
        <button class="mask__button--cancel" @click="cancel">取消</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    visable: {
      type: Boolean,
      default: () => false,
    },
  },

  methods: {
    success() {
      this.$emit("on-success");
    },
    cancel() {
      this.$emit("on-cancel");
    },
  },
};
</script>

<style scoped>
.mask {
  position: fixed;
  background: rgba(0, 0, 0, 0.5);
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}
.wrap {
  background-color: #fff;
  border-radius: 10px;
  width: 350px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}
.tip,
.content,
.button {
  margin: 10px 0;
}
.mask__button--success {
  outline: none;
  border: 0;
  background: blue;
  width: 100px;
  height: 40px;
  border-radius: 10px;
  margin: 0 20px;
  color: #fff;
}
.mask__button--cancel {
  outline: none;
  background: red;
  border: 0;
  width: 100px;
  height: 40px;
  border-radius: 30px;
  margin: 0 20px;
  color: #fff;
}
</style>
